package com.forcedotcom.model
{
	import com.forcedotcom.AccountConnection;
	import com.forcedotcom.components.PostItem;
	import com.salesforce.Util;
	import com.salesforce.objects.SObject;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	
	import mx.core.IUID;

	[Bindable]
	public class PostItemData implements IUID
	{
		public var post:SObject;
		public var connection:AccountConnection;
		public var postDate:Date;
		private var _uid:String;
		public var _profilePic:Bitmap;
		public var postItem:PostItem;
		private var bmData:BitmapData;
		
		public function set profilePic(img:Bitmap):void {
			trace("ProfilePic is being set on the post item data...");
			_profilePic = img;
			bmData = _profilePic.bitmapData;
			if (img != null) {
				postItem.profilePic = img;
			}
		}
		public function get profilePic():Bitmap {
			if (bmData != null) {
				return new Bitmap(bmData);
			} else {
				return null;
			}
		}
		public function PostItemData(post:SObject, connection:AccountConnection)
		{
			this.post = post;
			this.connection = connection;
			postDate = Util.stringToDateTime( post.CreatedDate );
			_uid = post.Id;
		}
		public function set uid(value:String):void {
			_uid = value;
		}
		public function get uid():String {
			return _uid;
		}
	}
}